package de.QuizCommunity;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.facebook.android.AsyncFacebookRunner;
import com.facebook.android.AsyncFacebookRunner.RequestListener;
import com.facebook.android.DialogError;
import com.facebook.android.Facebook;
import com.facebook.android.Facebook.DialogListener;
import com.facebook.android.FacebookError;
import com.facebook.android.Util;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class Social_Channel extends Activity {
	

	Integer i =0;
	protected static JSONArray jsonArray;
	Facebook facebook = Menue.facebook;


	RequestListener rL = new RequestListener() {
		
		public void onMalformedURLException(MalformedURLException e, Object state) {
			// TODO Auto-generated method stub
			
		}
		
		public void onIOException(IOException e, Object state) {
			// TODO Auto-generated method stub
			
		}
		
		public void onFileNotFoundException(FileNotFoundException e, Object state) {
			// TODO Auto-generated method stub
			
		}
		
		public void onFacebookError(FacebookError e, Object state) {
			// TODO Auto-generated method stub
			
		}
		
		public void onComplete(String response, Object state) {
			// TODO Auto-generated method stub
			
		}
	};
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.social_channel);
        final int frageID = getIntent().getIntExtra("frageID",0);
        
        DialogListener dL =  new DialogListener() {
    		
    		public void onFacebookError(FacebookError e) {
    			// TODO Auto-generated method stub
    			
    		}
    		
    		public void onError(DialogError e) {
    			
    		}
    		
    		public void onComplete(Bundle values) {
    			Intent in = new Intent(Social_Channel.this,Frage.class);
    			in.putExtra("frageID", frageID);
    			startActivity(in);
    			
    		}
    		
    		public void onCancel() {
    			Intent in = new Intent(Social_Channel.this,Frage.class);
    			in.putExtra("frageID", frageID);
    			startActivity(in);
    		}
    	};

			 Bundle params = new Bundle();
             params.putString("caption", "Test");
             params.putString("description",  "Test");
             params.putString("name",  "Test");
             
	        facebook.dialog(this, "feed",params, dL);

    }
}
